/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.cemaden.smp.controler;

import br.gov.cemaden.library.model.smp.Uptime;
import java.io.Serializable;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.TimeZone;

/**
 *
 * @author Simone Santos
 */
public class UptimeBean implements Serializable {

    Uptime up = new Uptime();

    public UptimeBean() {
    }

    public Uptime getUptime() {
        RuntimeMXBean remoteRuntime = ManagementFactory.getRuntimeMXBean();
        DateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");
        dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
        long uptime = remoteRuntime.getUptime();
        String d = uptime / (3600 * 1000 * 24) + ":" + dateFormat.format(uptime);

        up.setUptime(d);

        return up;
    }

    public void show(Uptime t) {
        System.out.println("Uptime" + t.getUptime());
    }
}
